/******************************************************************************
*
* MODULE:    SumadorParam.v
* DEVICE:     
* PROJECT:   Tarea 1 Diseño Electronico Digital
* AUTHOR:    Ricardo Dávila Castro   
* DATE:      2010 10:36:48
*
* ABSTRACT:   Sumador Parametizable un 4 bit Ejercicio Cuatro b)
*            
*******************************************************************************/
`ifndef 	SUMADORPARAM
`define    SUMADORPARAM
module SumadorParam (inA, inB,Cin,Cout,ResSum);

parameter LENGTH = 4; 

input [(LENGTH-1):0] inA;
input [(LENGTH-1):0] inB;
input Cin;

output [(LENGTH-1):0]ResSum;
output Cout;

wire [(LENGTH-1):0]Carry;
generate
	genvar i;
	
	for (i=0; i<LENGTH; i = i+1) 
	begin: sumBit
	 if (i==0)
			SumadorBit instSuma(.Op({inA[i],inB[i],Cin}),.OutCarry(Carry[i]),.ResultadoSum(ResSum[i]));
		else 
			SumadorBit instSuma(.Op({inA[i],inB[i],Carry[i-1]}),.OutCarry(Carry[i]),.ResultadoSum(ResSum[i]));
	end
endgenerate

assign Cout = Carry[(LENGTH-1)]; 

endmodule

`endif